<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*,util.*"%>
<%
	TaskModel obj;
	Object temp = request.getAttribute("task");
	if (temp != null) {
		try {
			obj = (TaskModel) temp;
		} catch (Exception ex) {
			obj = new TaskModel();
		}
	} else {
		obj = new TaskModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Update Task</title>

<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css"
	type="text/css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css"
	type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" />

<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.ui.widget.min.js"></script>

<script language="javascript" type="text/javascript"
	src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript"
	src="js/ajaxQuickInsert.js"></script>

<link rel="stylesheet" href="css/inputForm.css" />

<script language="javascript" type="text/javascript">
	var requiredInputs = [['name','name_required'],['code','code_required'],['description','description_required'],['id_employee','id_employee_required'],['id_type','id_type_required'],['status','status_required'],['plan_start_time','plan_start_time_date_required', 'plan_start_time','plan_start_time_time_required'],['plan_end_time','plan_end_time_date_required', 'plan_end_time','plan_end_time_time_required'],['real_start_tate','real_start_tate_date_required', 'real_start_tate','real_start_tate_time_required'],['real_end_time','real_end_time_date_required', 'real_end_time','real_end_time_time_required'],['notification','notification_required'],['rate','rate_required'],['id_parent','id_parent_required']];
	var intInputs = [['id_employee','id_employee_invalid'],['id_type','id_type_invalid'],['id_phase','id_phase_invalid'],['status','status_invalid'],['notification','notification_invalid'],['rate','rate_invalid'],['id_parent','id_parent_invalid']];
	var doubleInputs = [];
	var dateInputs = [['plan_start_time','plan_start_time_date_invalid'],['plan_end_time','plan_end_time_date_invalid'],['real_start_tate','real_start_tate_date_invalid'],['real_end_time','real_end_time_date_invalid']];
	var timeInputs = [['plan_start_time','plan_start_time_time_invalid'],['plan_end_time','plan_end_time_time_invalid'],['real_start_tate','real_start_tate_time_invalid'],['real_end_time','real_end_time_time_invalid']];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
	<jsp:include page="menu.jsp"></jsp:include>
	<br />
	<table>
		<tr>
			<td>
				<form action="task?mode=update" method="post"
					onSubmit="return checkInputs()"
					onreset="return confirm('Do you really want to reset the form?')">
					<table class="tblInput" border="1">
						<tr class="inputHeader">
							<th colspan="3" class="inputHeader">Create New Task</th>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Id</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="id" name="id" readonly="readonly" value="<%=obj.getId()%>" />
							</td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput"><input class="inputText"
								type="text" id="name" name="name" maxlength="255"
								value="<%=obj.getNameToString()%>" /></td>
							<td class="tdErrMsg"><span id="name_required" class="errMsg"
								style="display: none;">Name is required</span> <span
								id="name_invalid" class="errMsg" style="display: none;">Name
									is invalid</span> <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Code</td>
							<td class="tdFieldInput"><input class="inputText"
								type="text" id="code" name="code" maxlength="20"
								value="<%=obj.getCodeToString()%>" /></td>
							<td class="tdErrMsg"><span id="code_required" class="errMsg"
								style="display: none;">Code is required</span> <span
								id="code_invalid" class="errMsg" style="display: none;">Code
									is invalid</span> <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Description</td>
							<td class="tdFieldInput"><textarea id="description"
									name="description" rows="5" class="inputTextarea"><%=obj.getDescriptionToString()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="description_required"
								class="errMsg" style="display: none;">Description is
									required</span> <span id="description_invalid" class="errMsg"
								style="display: none;">Description is invalid</span> <span
								id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Id Employee</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="id_employee" name="id_employee" maxlength="10"
								value="<%=obj.getIdEmployeeToString()%>" /></td>
							<td class="tdErrMsg"><span id="id_employee_required"
								class="errMsg" style="display: none;">Id Employee is
									required</span> <span id="id_employee_invalid" class="errMsg"
								style="display: none;">Id Employee is invalid</span> <span
								id="id_employee_error" class="errMsg"><%=obj.errMsgs.IdEmployee%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Id Type</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="id_type" name="id_type" maxlength="10"
								value="<%=obj.getIdTypeToString()%>" /></td>
							<td class="tdErrMsg"><span id="id_type_required"
								class="errMsg" style="display: none;">Id Type is required</span>
								<span id="id_type_invalid" class="errMsg" style="display: none;">Id
									Type is invalid</span> <span id="id_type_error" class="errMsg"><%=obj.errMsgs.IdType%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Id Phase</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="id_phase" name="id_phase" maxlength="10"
								value="<%=obj.getIdPhaseToString()%>" /></td>
							<td class="tdErrMsg"><span id="id_phase_required"
								class="errMsg" style="display: none;">Id Phase is
									required</span> <span id="id_phase_invalid" class="errMsg"
								style="display: none;">Id Phase is invalid</span> <span
								id="id_phase_error" class="errMsg"><%=obj.errMsgs.IdPhase%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Status</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="status" name="status" maxlength="10"
								value="<%=obj.getStatusToString()%>" /></td>
							<td class="tdErrMsg"><span id="status_required"
								class="errMsg" style="display: none;">Status is required</span>
								<span id="status_invalid" class="errMsg" style="display: none;">Status
									is invalid</span> <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Plan Start Time</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="plan_start_time_date"
											name="plan_start_time_date"
											value="<%=StringUtil.toDateTimeString(obj.getPlanStartTime())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('plan_start_time_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="plan_start_time_time"
											name="plan_start_time_time"
											value="<%=obj.getPlanStartTime()%>" /></td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="plan_start_time_error"
								class="errMsg"><%=obj.errMsgs.PlanStartTime%></span>
								<div class="divErr">
									<span id="plan_start_time_date_required" class="errMsg"
										style="display: none;">Plan Start Time's date is
										required</span>
								</div>
								<div class="divErr">
									<span id="plan_start_time_time_required" class="errMsg"
										style="display: none;">Plan Start Time's time is
										required</span>
								</div>
								<div class="divErr">
									<span id="plan_start_time_date_invalid" class="errMsg"
										style="display: none;">Plan Start Time's date is
										invalid</span>
								</div>
								<div class="divErr">
									<span id="plan_start_time_time_invalid" class="errMsg"
										style="display: none;">Plan Start Time's time is
										invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Plan End Time</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="plan_end_time_date"
											name="plan_end_time_date"
											value="<%=StringUtil.toDateTimeString(obj.getPlanEndTime())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('plan_end_time_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="plan_end_time_time"
											name="plan_end_time_time" value="<%=obj.getPlanEndTime()%>" />
										</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="plan_end_time_error"
								class="errMsg"><%=obj.errMsgs.PlanEndTime%></span>
								<div class="divErr">
									<span id="plan_end_time_date_required" class="errMsg"
										style="display: none;">Plan End Time's date is required</span>
								</div>
								<div class="divErr">
									<span id="plan_end_time_time_required" class="errMsg"
										style="display: none;">Plan End Time's time is required</span>
								</div>
								<div class="divErr">
									<span id="plan_end_time_date_invalid" class="errMsg"
										style="display: none;">Plan End Time's date is invalid</span>
								</div>
								<div class="divErr">
									<span id="plan_end_time_time_invalid" class="errMsg"
										style="display: none;">Plan End Time's time is invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Real Start Tate</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="real_start_tate_date"
											name="real_start_tate_date"
											value="<%=StringUtil.toDateTimeString(obj.getRealStartTate())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('real_start_tate_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="real_start_tate_time"
											name="real_start_tate_time"
											value="<%=obj.getRealStartTate()%>" /></td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="real_start_tate_error"
								class="errMsg"><%=obj.errMsgs.RealStartTate%></span>
								<div class="divErr">
									<span id="real_start_tate_date_required" class="errMsg"
										style="display: none;">Real Start Tate's date is
										required</span>
								</div>
								<div class="divErr">
									<span id="real_start_tate_time_required" class="errMsg"
										style="display: none;">Real Start Tate's time is
										required</span>
								</div>
								<div class="divErr">
									<span id="real_start_tate_date_invalid" class="errMsg"
										style="display: none;">Real Start Tate's date is
										invalid</span>
								</div>
								<div class="divErr">
									<span id="real_start_tate_time_invalid" class="errMsg"
										style="display: none;">Real Start Tate's time is
										invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Real End Time</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="real_end_time_date"
											name="real_end_time_date"
											value="<%=StringUtil.toDateTimeString(obj.getRealEndTime())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('real_end_time_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="real_end_time_time"
											name="real_end_time_time" value="<%=obj.getRealEndTime()%>" />
										</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"><span id="real_end_time_error"
								class="errMsg"><%=obj.errMsgs.RealEndTime%></span>
								<div class="divErr">
									<span id="real_end_time_date_required" class="errMsg"
										style="display: none;">Real End Time's date is required</span>
								</div>
								<div class="divErr">
									<span id="real_end_time_time_required" class="errMsg"
										style="display: none;">Real End Time's time is required</span>
								</div>
								<div class="divErr">
									<span id="real_end_time_date_invalid" class="errMsg"
										style="display: none;">Real End Time's date is invalid</span>
								</div>
								<div class="divErr">
									<span id="real_end_time_time_invalid" class="errMsg"
										style="display: none;">Real End Time's time is invalid</span>
								</div></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Need Approval</td>
							<td class="tdFieldInput">
								<table class="tblBool">
									<tr class="trBoolSet">
										<td colspan="2" class="tdBoolSet"><input type="checkbox"
											id="ckb_need_approval" name="ckb_need_approval"
											onchange="toggleControls(['need_approval_true', 'need_approval_false'])" />Not
											set</td>
									</tr>
									<tr class="trBool">
										<td class="tdBool"><input type="radio"
											id="need_approval_true" name="need_approval" value="1"
											checked="checked" />Yes</td>
										<td class="tdBool"><input type="radio"
											id="need_approval_false" name="need_approval" value="0" />No</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Is Event</td>
							<td class="tdFieldInput">
								<table class="tblBool">
									<tr class="trBoolSet">
										<td colspan="2" class="tdBoolSet"><input type="checkbox"
											id="ckb_is_event" name="ckb_is_event"
											onchange="toggleControls(['is_event_true', 'is_event_false'])" />Not
											set</td>
									</tr>
									<tr class="trBool">
										<td class="tdBool"><input type="radio" id="is_event_true"
											name="is_event" value="1" checked="checked" />Yes</td>
										<td class="tdBool"><input type="radio"
											id="is_event_false" name="is_event" value="0" />No</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Is Draft</td>
							<td class="tdFieldInput">
								<table class="tblBool">
									<tr class="trBoolSet">
										<td colspan="2" class="tdBoolSet"><input type="checkbox"
											id="ckb_is_draft" name="ckb_is_draft"
											onchange="toggleControls(['is_draft_true', 'is_draft_false'])" />Not
											set</td>
									</tr>
									<tr class="trBool">
										<td class="tdBool"><input type="radio" id="is_draft_true"
											name="is_draft" value="1" checked="checked" />Yes</td>
										<td class="tdBool"><input type="radio"
											id="is_draft_false" name="is_draft" value="0" />No</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Notification</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="notification" name="notification" maxlength="10"
								value="<%=obj.getNotificationToString()%>" /></td>
							<td class="tdErrMsg"><span id="notification_required"
								class="errMsg" style="display: none;">Notification is
									required</span> <span id="notification_invalid" class="errMsg"
								style="display: none;">Notification is invalid</span> <span
								id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Created</td>
							<td class="tdFieldInput"><span class="inputText"><%=obj.getCreatedToString()%></span>
							</td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Creator</td>
							<td class="tdFieldInput"><span class="inputText"><%=obj.getCreatorToString()%></span>
							</td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Updated</td>
							<td class="tdFieldInput"><span class="inputText"><%=obj.getUpdatedToString()%></span>
							</td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Updator</td>
							<td class="tdFieldInput"><span class="inputText"><%=obj.getUpdatorToString()%></span>
							</td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Deleted</td>
							<td class="tdFieldInput">
								<table class="tblBool">
									<tr class="trBoolSet">
										<td colspan="2" class="tdBoolSet"><input type="checkbox"
											id="ckb_deleted" name="ckb_deleted"
											onchange="toggleControls(['deleted_true', 'deleted_false'])" />Not
											set</td>
									</tr>
									<tr class="trBool">
										<td class="tdBool"><input type="radio" id="deleted_true"
											name="deleted" value="1" checked="checked" />Yes</td>
										<td class="tdBool"><input type="radio" id="deleted_false"
											name="deleted" value="0" />No</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Deletion Time</td>
							<td class="tdFieldInput"><span class="inputText"><%=obj.getDeletionTimeToString()%></span>
							</td>
							<td class="tdErrMsg"></td>
						<tr class="trField">
							<td class="tdFieldName">Rate</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="rate" name="rate" maxlength="10"
								value="<%=obj.getRateToString()%>" /></td>
							<td class="tdErrMsg"><span id="rate_required" class="errMsg"
								style="display: none;">Rate is required</span> <span
								id="rate_invalid" class="errMsg" style="display: none;">Rate
									is invalid</span> <span id="rate_error" class="errMsg"><%=obj.errMsgs.Rate%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Is Group</td>
							<td class="tdFieldInput">
								<table class="tblBool">
									<tr class="trBoolSet">
										<td colspan="2" class="tdBoolSet"><input type="checkbox"
											id="ckb_is_group" name="ckb_is_group"
											onchange="toggleControls(['is_group_true', 'is_group_false'])" />Not
											set</td>
									</tr>
									<tr class="trBool">
										<td class="tdBool"><input type="radio" id="is_group_true"
											name="is_group" value="1" checked="checked" />Yes</td>
										<td class="tdBool"><input type="radio"
											id="is_group_false" name="is_group" value="0" />No</td>
									</tr>
								</table>
							</td>
							<td class="tdErrMsg"></td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Id Parent</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="id_parent" name="id_parent" maxlength="10"
								value="<%=obj.getIdParentToString()%>" /></td>
							<td class="tdErrMsg"><span id="id_parent_required"
								class="errMsg" style="display: none;">Id Parent is
									required</span> <span id="id_parent_invalid" class="errMsg"
								style="display: none;">Id Parent is invalid</span> <span
								id="id_parent_error" class="errMsg"><%=obj.errMsgs.IdParent%></span>
							</td>
						</tr>

						<tr class="trInputBottom">
							<td class="tdInputBottom" colspan="3"><input type="submit"
								value="Submit" /></td>
						</tr>
					</table>
				</form></td>
		</tr>
	</table>
	<br />
	<jsp:include page="taskList.jsp?embedded=true"></jsp:include>
</body>
</html>